package com.qinggeng.project.system.controller;

import com.qinggeng.framework.aspectj.lang.annotation.Log;
import com.qinggeng.framework.aspectj.lang.enums.BusinessType;
import com.qinggeng.framework.web.controller.BaseController;
import com.qinggeng.framework.web.domain.AjaxResult;
import com.qinggeng.framework.web.page.TableDataInfo;
import com.qinggeng.project.system.domain.AppConfig;
import com.qinggeng.project.system.service.AppConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * app配置控制器
 * @author Gaoao
 * @date 2020-02-11
 */
@RestController
@RequestMapping("/app")
public class AppConfigController extends BaseController {

    @Autowired
    private AppConfigService appConfigService;

    /**
     * app配置列表
     * @param appConfig 查询条件
     * @return
     */
    @PreAuthorize("@ss.hasPermi('app:appConfig:list')")
    @GetMapping("/appConfig/list")
    public TableDataInfo list(AppConfig appConfig)
    {
        List<AppConfig> list = appConfigService.queryAppConfigList(appConfig);
        return getDataTable(list);
    }
    /**
     * app配置详情
     * @param id
     * @return
     */
    @PreAuthorize("@ss.hasPermi('app:appConfig:query')")
    @GetMapping(value = "/appConfig/{id}")
    public AjaxResult getInfo(@PathVariable Integer id)
    {
        return AjaxResult.success(appConfigService.findAppConfigById(id));
    }
    /**
     * app配置添加
     * @param appConfig 数据
     * @return
     */
    @PreAuthorize("@ss.hasPermi('app:appConfig:add')")
    @Log(title = "app配置添加", businessType = BusinessType.INSERT)
    @PostMapping("/appConfig")
    public AjaxResult add(@Validated @RequestBody AppConfig appConfig)
    {
        return toAjax(appConfigService.createAppConfig(appConfig));
    }
    /**
     * app配置编辑
     * @param appConfig 数据
     * @return
     */
    @PreAuthorize("@ss.hasPermi('app:appConfig:edit')")
    @Log(title = "app配置编辑", businessType = BusinessType.UPDATE)
    @PutMapping("/appConfig")
    public AjaxResult edit(@Validated @RequestBody AppConfig appConfig)
    {
        return toAjax(appConfigService.updateAppConfig(appConfig));
    }
    /**
     * app配置删除
     * @param id
     * @return
     */
    @PreAuthorize("@ss.hasPermi('app:appConfig:remove')")
    @Log(title = "app配置删除", businessType = BusinessType.DELETE)
    @DeleteMapping("/appConfig/{id}")
    public AjaxResult remove(@PathVariable Integer id)
    {
        return toAjax(appConfigService.deleteAppConfigById(id));
    }
}
